package com.liyunhan.Test;

import com.liyunhan.SortAlgorithm.*;

import java.util.ArrayList;
import java.util.Random;

/**
 * @Description: 测试类
 * @Author: Liyunhan
 * @Date: 2021/10/3 21:29
 */
public class MyTest {
    public static void main(String[] args) {
        ArrayList<Double> arrayList = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 100000; i++) {
            arrayList.add(random.nextDouble()*10000);
        }
//        for (int i = 0; i < 100; i++) {
//            arrayList.add(random.nextDouble()*1000);
//        }
//        System.out.println(arrayList);
//        arrayList.add(13.0);
//        arrayList.add(23.5);
//        arrayList.add(-93.0);
//        arrayList.add(103.1);
//        arrayList.add(11.0);
//        arrayList.add(9.7);
//        arrayList.add(9.6);
//        arrayList.add(4.7);
//        arrayList.add(0.0);
//        arrayList.add(27.3);
//        arrayList.add(27.3);
//        arrayList.add(-11.0);
        //BubbleSort
        AlgorithmAbs bubbleSort = new BubbleSort(arrayList);
        System.out.println("BubbleSort算法运行时间为:" + bubbleSort.start());
//        System.out.println("排序后序列为:" + bubbleSort.getArrayList());


        //ShellSort
        AlgorithmAbs shellSort = new ShellSort(arrayList);
        System.out.println("ShellSort算法运行时间为:" + shellSort.start());
//        System.out.println("排序后序列为:" + shellSort.getArrayList());

        //QuickSortRecursion
        AlgorithmAbs quickSortRecursion = new QuickSortRecursion(arrayList);
        System.out.println("QuickSortRecursion算法运行时间为:" + quickSortRecursion.start(0, arrayList.size()-1));
//        System.out.println("排序后序列为:" + quickSortRecursion.getArrayList());

        //QuickSortNonRecursion
        AlgorithmAbs quickSortNonRecursion = new QuickSortNonRecursion(arrayList);
        System.out.println("QuickSortNonRecursion算法运行时间为:" + quickSortNonRecursion.start(0, arrayList.size()-1));
//        System.out.println("排序后序列为:" + quickSortNonRecursion.getArrayList());

        //QuickSortRecursionImprovement
        AlgorithmAbs quickSortRecursionImprovement = new QuickSortRecursionImprovement(arrayList);
        System.out.println("QuickSortRecursionImprovement算法运行时间为:" + quickSortRecursionImprovement.start(0, arrayList.size()-1));
//        System.out.println("排序后序列为:" + quickSortRecursion.getArrayList());

//        System.out.println(arrayList);
    }
}
